﻿package mortal.game.view.copy.sixBoss.view
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.component.windowTip.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.treasureHunt.renderer.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class SixBossEnterWin extends ActivityBaseWindow
    {
        private var _rewardItemList:GTileList;
        private var _btnDetailPlay:GButton;
        private static var _instance:SixBossEnterWin;

        public function SixBossEnterWin(param1:ILayer = null, param2:String = "", param3:String = "")
        {
            setSize(802, 446);
            super(param1, ImagesConst.SixBossTitle, ImagesConst.SixBossEnterWinBg);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41387), 317 - 15, 61 - 35, 203 + 25, 25, this, GlobalStyle.textFormatLv.setSize(14)));
            this._rewardItemList = UIFactory.tileList(177, 342 - 29 + 45, 275, 45, this.contentTopOf3DSprite);
            this._rewardItemList.columnWidth = 44;
            this._rewardItemList.rowHeight = 43;
            this._rewardItemList.horizontalGap = 0;
            this._rewardItemList.verticalGap = 0;
            this._rewardItemList.setStyle("skin", new Bitmap());
            this._rewardItemList.setStyle("cellRenderer", TreasureRewardItemCellRenderer);
            this._btnDetailPlay = UIFactory.gButton(Language.getString(41388), 537, 356 - 33 + 42, 65, 22, this.contentTopOf3DSprite, "GreenLinkButton");
            this._btnDetailPlay.configEventListener(MouseEvent.CLICK, this.onClickDetailPlay);
            this.initBossInfo();
            this.initItemList();
            return;
        }// end function

        private function initBossInfo() : void
        {
            var _loc_2:SixBossInfoSpr = null;
            var _loc_1:int = 0;
            while (_loc_1 < 6)
            {
                
                _loc_2 = UICompomentPool.getUICompoment(SixBossInfoSpr);
                this.pushUIToDisposeVec(_loc_2);
                _loc_2.x = 29 + 129 * _loc_1;
                _loc_2.y = 271 - 36;
                _loc_2.index = _loc_1;
                this.addChild(_loc_2);
                if (_loc_1 < 2)
                {
                    _loc_2.setStarLevel(1);
                }
                else if (_loc_1 < 4)
                {
                    _loc_2.setStarLevel(2);
                }
                else
                {
                    _loc_2.setStarLevel(3);
                }
                _loc_1++;
            }
            return;
        }// end function

        private function initItemList() : void
        {
            var _loc_1:Array = [];
            var _loc_2:* = CopyConfig.instance.getCopyInfoByCode(150);
            if (_loc_2 && _loc_2.rewardShow)
            {
                _loc_1 = _loc_2.rewardShow.split("#");
            }
            var _loc_3:Array = [];
            var _loc_4:int = 0;
            while (_loc_4 < _loc_1.length)
            {
                
                _loc_3.push(new ItemData(int(_loc_1[_loc_4])));
                _loc_4++;
            }
            var _loc_5:* = new DataProvider();
            _loc_5.addItems(_loc_3);
            this._rewardItemList.dataProvider = _loc_5;
            this._rewardItemList.drawNow();
            this._rewardItemList.x = (this.width - this._rewardItemList.columnWidth * this._rewardItemList.length) / 2 + 2;
            return;
        }// end function

        private function onClickDetailPlay(event:MouseEvent) : void
        {
            var _loc_2:* = new WindowTipData();
            _loc_2.type = WindowTipType.TreasureHunt_Detail;
            _loc_2.tip = Language.getString(40800);
            _loc_2.title = Language.getString(41388);
            _loc_2.tipW = 500;
            _loc_2.tipH = 500;
            WindowTipManager.showTip(_loc_2);
            return;
        }// end function

        override protected function onClickEnterBtn(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SixBossEnterCopy));
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            WindowTipManager.hideTip(WindowTipType.TreasureHunt_Detail);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._rewardItemList.dispose();
            this._rewardItemList = null;
            this._btnDetailPlay.dispose();
            this._btnDetailPlay = null;
            return;
        }// end function

        public static function get instance() : SixBossEnterWin
        {
            if (!_instance)
            {
                _instance = new SixBossEnterWin;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
